<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:pe="http://primefaces.org/ui/extensions"
	template="/WEB-INF/templates/template.xhtml">
	
<ui:define name="headIncludes">
	<f:event listener="#{servicoBean.initializeForm(param.servicoId)}" type="preRenderView"/>
	
	<style>
		.panel100 {
			width:100px;
		}
		
		.panel120 {
			width: 120px;
		}
		
		.classBold {
			font-weight: bold;
		}
	</style>
</ui:define>
	
	<ui:define name="pageName">Detalhe de Serviço</ui:define>
	
	<ui:define name="buttons">
		<p:commandButton value="Editar" style="height:28px;" action="#{servicoBean.changeToEdit}" icon="ui-icon-pencil"/>
		<p:commandButton value="Excluir" style="height:28px;" onclick="popupConfirmDeleteDetail.show()" icon="ui-icon-trash"/>
		<p:commandButton value="Voltar" style="height:28px;" action="#{servicoBean.changeToList}" process="@this" icon="ui-icon-arrowreturnthick-1-w"/>
	</ui:define>
	
	<ui:define name="content">	
		<p:panel>
			<div>
				<p:messages autoUpdate="true" closable="true"/>
				
				<h:panelGrid columns="2" style="padding:5px;" columnClasses="panel100">
					<h:outputText styleClass="classBold" value="Código" />
					<h:outputText styleClass="classBold" value="Descrição" />
					
					<h:outputText value="#{servicoBean.currentServico.id}"/>
					<h:outputText value="#{servicoBean.currentServico.descricao}"/>
				</h:panelGrid>
			
				<h:panelGrid columns="4" style="padding:5px;" columnClasses="panel120, panel120, panel120">			
					<h:outputText styleClass="classBold" value="Valor mão de obra" />			
					<h:outputText styleClass="classBold" value="Valor do serviço" />	
					<h:outputText styleClass="classBold" value="Comissão" />	
					<h:outputText styleClass="classBold" value="Tempo médio" />
					
					<h:outputText value="#{servicoBean.currentServico.valorMaoObra}">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText value="#{servicoBean.currentServico.valorServico}">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText value="#{servicoBean.currentServico.comissao}">
						<f:convertNumber pattern="R$ #,###,##0.00" />
					</h:outputText>
					
					<h:outputText value="#{servicoBean.currentServico.tempoMedio}"/>
				</h:panelGrid>
	
				<h:panelGrid columns="1" style="padding:5px;">	
					<h:outputText styleClass="classBold" value="Observações" />		
					<h:outputText value="#{servicoBean.currentServico.observacao}"/>	
				</h:panelGrid>
				
				<div style="padding-top:10px;">
					<p:dataTable var="funcionario" 
						value="#{servicoBean.currentFuncionarios}" rendered="#{servicoBean.currentServico.funcionarios.size() > 0}"
						paginator="true" rows="10" paginatorPosition="bottom"
						emptyMessage="Não há registros" id="tableFuncionarios">
						  
						<p:column headerText="Código" style="width:150px;">  
					    	<h:outputText value="#{funcionario.id}" />  
						</p:column>  
					 
						<p:column headerText="Nome">  
					    	<h:outputText value="#{funcionario.nome}" />  
						</p:column> 	
				  	</p:dataTable>
				</div>
			</div>
		</p:panel>				
	</ui:define>
		<ui:define name="popups">	
		<ui:include src="listFuncionario.xhtml"/>
		
		<p:dialog appendToBody="true" modal="true" closable="false" widgetVar="popupConfirmDeleteDetail"
			width="300" resizable="false" header="Confirmação de exclusão" height="90">
			<h:form>
				<div style="margin-top: 10px;">
					<h:outputText value="Confirma a exclusão do registro?"/>
				</div>
				<div align="right" style="margin-top: 15px; margin-bottom: 15px;">
					<p:commandButton value="Excluir" actionListener="#{servicoBean.removeFromDetail}" oncomplete="popupConfirmDeleteDetail.hide()" icon="ui-icon-trash"/>
					<p:commandButton value="Cancelar" onclick="popupConfirmDeleteDetail.hide()" icon="ui-icon-cancel"/>
				</div>		
			</h:form>			
		</p:dialog>
		
		<p:dialog id="completeDialogDelete" header="Confirmação de exclusão" closable="false"
			widgetVar="completeDeletePopup" width="300" resizable="false">
			<h:form>
				<div style="margin-top: 10px;">Excluído com sucesso!</div>
				
				<div align="right" style="margin-top: 15px; margin-bottom: 15px;" > 
					<p:commandButton id="complete" value="Fechar" oncomplete="completeDeletePopup.hide()" icon="ui-icon-close" 
						action="#{servicoBean.changeToList}" />
				</div>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>